/**
 * Copyright 2004-2048 .
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.ipd.jsf.gd.error;


import java.io.Serializable;

import com.ipd.jsf.gd.msg.MessageHeader;

/**
 * Title: 远程调用执行时抛出的异常<br>
 * <p/>
 * Description: <br>
 * <p/>
 */
public class RpcException extends RuntimeException implements Serializable {

    /**
     *
     */
    private static final long serialVersionUID = 7772360050382788166L;

    private int errorCode = 2;

    protected String errorMsg;

    private transient MessageHeader msgHeader;

    // 需要序列化支持
    protected RpcException() {
    }


    public RpcException(MessageHeader header, Throwable e) {
        super(e);
        this.msgHeader = header;

    }

    public RpcException(MessageHeader header, String errorMsg) {
        super(errorMsg);
        this.msgHeader = header;
        this.errorMsg = errorMsg;
    }

    protected RpcException(Throwable e) {
        super(e);
    }

    public RpcException(String errorMsg) {
        super(errorMsg);
        this.errorMsg = errorMsg;
    }

    public RpcException(String errorMsg, Throwable e) {
        super(errorMsg, e);
        this.errorMsg = errorMsg;
    }

    public MessageHeader getMsgHeader() {
        return msgHeader;
    }

    public void setMsgHeader(MessageHeader msgHeader) {
        this.msgHeader = msgHeader;
    }

    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }


    public String toString() {
        String s = getClass().getName();
        String message = this.errorMsg;
        return (message != null) ? (s + ": " + message) : s;
    }


}